<template>
    <add-comment
        v-if="data"
        :msgRequired="false"
        :data="data"
        @addCommentFn="addCommentFn"
        :style="themeColor"></add-comment>
</template>

<script>
import addComment from "@/uni-sub-base/components/comment/add-comment.vue"

import { OrderComment } from "@/service/api/order.js"
import { mapMutations } from "vuex"
export default {
    components: {
        addComment,
    },
    data() {
        return {
            data: null,
            order: {},
            submitone: true,
        }
    },
    onLoad(e) {
        this.order = JSON.parse(decodeURIComponent(e.data))
        this.data = this.order.DetailList
    },
    mounted() {},
    methods: {
        ...mapMutations(["UP_ORDER_VIEW"]),
        addCommentFn(e) {
            if (this.submitone) {
                this.submitone = false
                let param = {
                    commentList: e,
                    id: this.order.OrderId,
                }
                OrderComment(param).then((res) => {
                    if (res.State == 1) {
                        //更新列表
                        this.UP_ORDER_VIEW(new Date().getTime())
                        this.easyGoBack()
                        setTimeout((e) => {
                            this.submitone = true
                        }, 1000)
                    } else {
                        this.easyToast(res.Msg)
                    }
                })
            }
        },
    },
}
</script>

<style lang="scss" scope></style>
